package com.ruoyi.wareManagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wareManagement.domain.InventoryJournalInquiry;
import com.ruoyi.wareManagement.service.IInventoryJournalInquiryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库存流水查询Controller
 * 
 * @author admin
 * @date 2024-07-01
 */
@RestController
@RequestMapping("/wareManagement/inventoryJournal")
public class InventoryJournalInquiryController extends BaseController
{
    @Autowired
    private IInventoryJournalInquiryService inventoryJournalInquiryService;

    /**
     * 查询库存流水查询列表
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:inventoryJournal:list')")
    @GetMapping("/list")
    public TableDataInfo list(InventoryJournalInquiry inventoryJournalInquiry)
    {
        startPage();
        List<InventoryJournalInquiry> list = inventoryJournalInquiryService.selectInventoryJournalInquiryList(inventoryJournalInquiry);
        return getDataTable(list);
    }

    /**
     * 导出库存流水查询列表
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:inventoryJournal:export')")
    @Log(title = "库存流水查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InventoryJournalInquiry inventoryJournalInquiry)
    {
        List<InventoryJournalInquiry> list = inventoryJournalInquiryService.selectInventoryJournalInquiryList(inventoryJournalInquiry);
        ExcelUtil<InventoryJournalInquiry> util = new ExcelUtil<InventoryJournalInquiry>(InventoryJournalInquiry.class);
        util.exportExcel(response, list, "库存流水查询数据");
    }

    /**
     * 获取库存流水查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:inventoryJournal:query')")
    @GetMapping(value = "/{journalId}")
    public AjaxResult getInfo(@PathVariable("journalId") Long journalId)
    {
        return success(inventoryJournalInquiryService.selectInventoryJournalInquiryByJournalId(journalId));
    }

    /**
     * 新增库存流水查询
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:inventoryJournal:add')")
    @Log(title = "库存流水查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InventoryJournalInquiry inventoryJournalInquiry)
    {
        return toAjax(inventoryJournalInquiryService.insertInventoryJournalInquiry(inventoryJournalInquiry));
    }

    /**
     * 修改库存流水查询
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:inventoryJournal:edit')")
    @Log(title = "库存流水查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InventoryJournalInquiry inventoryJournalInquiry)
    {
        return toAjax(inventoryJournalInquiryService.updateInventoryJournalInquiry(inventoryJournalInquiry));
    }

    /**
     * 删除库存流水查询
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:inventoryJournal:remove')")
    @Log(title = "库存流水查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{journalIds}")
    public AjaxResult remove(@PathVariable Long[] journalIds)
    {
        return toAjax(inventoryJournalInquiryService.deleteInventoryJournalInquiryByJournalIds(journalIds));
    }
}
